//
//  MYRecommendViewController.m
//  投融保
//
//  Created by 523 on 13-12-16.
//  Copyright (c) 2013年 木叶科技. All rights reserved.
//

#import "MYRecommendViewController.h"
#import "proCell.h"
#import "MYHelpViewController.h"
#import "MYInvestorListsViewController.h"
#import "MYChangePdViewController.h"
#import "MYFeedbackViewController.h"
#import "MYAboutViewController.h"
#import "MYOperateViewController.h"
#import "MYCardTableViewController.h"
#import "InvestmentContentViewController.h"
#import "userAccount.h"
#import "notifactionView.h"
#import "MYStatisticsViewController.h"
#import "MYChangePhoneNoViewController.h"
#import "proList.h"
#import "MYTransferredInVC.h"
#import "ApplyTransferredOutVC.h"
#import "PubicView.h"
#import "RecordCell.h"
#import "ApplyTransferredinVC.h"
#import "TransforCell.h"
#import "TouZiXQ.h"
#import "MYPersonalInfoViewController.h"
#import "SVPullToRefresh.h"
#import "NSDate+NSDate_NowToLastDate.h"
#import "MYAgentCreated.h"


@interface MYRecommendViewController ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate>{
    
    int Y;
    UIView *proView;
    UIView *myAccountView;
    UIScrollView *accountMangeView;
    UIScrollView *moreView;
    UITableView *contentTableView;
    UIScrollView *contentScroll;
    UIPageControl *pageControl;
    UIScrollView *recordScroll;
    UITableView *recordTable;
    UILabel *countLable;
    BOOL viewBool ;
    BOOL isOpen1;
    BOOL isOpen2;
    BOOL isOpen3;
    UIView *shouYiView;
    UIView *dateView ;
    UIView *companyView;
    NSInteger indexTag;
    NSString *starTime;
    NSString *endTime;
    NSString *starRate;
    NSString *endRate;
    int pageNo1;
    int pageNo2;
    int pageNo3;
    int pageNo4;
    int pageNo5;
    BOOL isScreen;
    BOOL isFirst;
    NSString *strIndexTrade1;
    NSString *strIndexTrade2;
}
@property (nonatomic, strong)UILabel *nameLable;        //用户名
@property (nonatomic, strong)UILabel *balanceLable;//余额多少
@property (nonatomic, strong)UIImageView *userHeadImage;//用户头像
@property(nonatomic,strong)NSMutableArray *arrtouzi;//投资记录数据
@property(nonatomic,strong)NSMutableArray *arrhuaru;//划入记录数据
@property(nonatomic,strong)NSMutableArray *arrhuachu;//划出记录数据
@property(nonatomic,strong)NSMutableArray *finishProArr;//划入记录数据
@property(nonatomic,strong)NSMutableArray *unFinishProArr;//划出记录数据
@property(nonatomic ,strong)UIScrollView *testScroll;
@end

@implementation MYRecommendViewController
@synthesize arrhuachu,arrhuaru,arrtouzi,testScroll,finishProArr,unFinishProArr;
extern NSDictionary *accountDic;//帐户状态  认证  余额
extern NSDictionary *userInformation ;//用户信息
extern NSString *key;
extern NSString *appKey;
extern NSDictionary *loginDic;
extern bool loginFlag;
extern float j;//
extern NSString *userRole;

@synthesize nameLable,balanceLable,userHeadImage;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        
        
    }
    return self;
}
- (void)viewDidAppear:(BOOL)animated{
    
    
    
}

- (void)viewWillAppear:(BOOL)animated
{   //刷新用户信息
    MYWebService *service=[MYWebService new];
    NSString *strPersonalInfoService=@"service=personalInfoService";
    NSString *strQueryAcountInfoService=@"service=queryAcountInfo";
    MBProgressHUD *mbHudre = [[MBProgressHUD alloc] initWithView:self.view];
    
    mbHudre.labelText = @"加载中··";
    
    [self.view addSubview:mbHudre];
    
    //    mbHudre.delegate =self;
    
    [mbHudre showAnimated:YES whileExecutingBlock:^{
        
        //z菊花转动的时候 开始加载数据
        userInformation = [service getDataSynWithKey:key encryptedString:strPersonalInfoService appKey:appKey];
        accountDic = [service getDataSynWithKey:key encryptedString:strQueryAcountInfoService appKey:appKey];
        
    } completionBlock:^{
        
        //执行加载数据完成后的操作。
        balanceLable.text = [NSString stringWithFormat:@"账户余额:%@",[accountDic valueForKey:@"availableBalance"]];
        
    }];
    //    userInformation = [service getDataSynWithKey:key encryptedString:strPersonalInfoService appKey:appKey];
    //    accountDic = [service getDataSynWithKey:key encryptedString:strQueryAcountInfoService appKey:appKey];
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getNotifi:) name:@"getAsyData" object:nil];
    SETBACKGROUND
    
    viewBool =NO;
    isOpen1 = NO;
    isOpen2 = NO;
    isOpen3 = NO;
    isScreen = NO;
    userRole = [userInformation valueForKey:@"role"];
    [self setHttpPage];
    [self initView];
}
-(void)setHttpPage{
    if (unFinishProArr==nil||finishProArr==nil) {
        pageNo1 = 2;
        pageNo2 = 2;
        pageNo3 = 1;
        pageNo4 = 1;
        pageNo5 = 1;
    }else {
        pageNo1 = unFinishProArr.count/10;
        pageNo2 = finishProArr.count/10;
        pageNo3 = arrtouzi.count/10;
        pageNo4 = arrhuaru.count/10;
        pageNo5 = arrhuachu.count/10;
        
    }
    
}

-(void)initView{
    //顶部账户视图
    Y=0;
    if (IOS_VERSION>=7.0) {
        Y=20;
    }
    UIImageView *topImage =[[UIImageView alloc]initWithFrame:CGRectMake(0.0, Y, SCREEN_WIDTH, 174)];
    topImage.image = [UIImage imageNamed:@"top@2x-03"];//topInformation
    nameLable =[[UILabel alloc]initWithFrame:CGRectMake(40, 25, 200, 60)];
    if (![[NSString stringWithFormat:@"%@",[userInformation valueForKey:@"realName"]]isEqualToString:@"<null>"]) {
        nameLable.text = @"";
        nameLable.text =[NSString stringWithFormat:@"%@",[userInformation valueForKey:@"realName"]];
        NSLog(@"%@",[NSString stringWithFormat:@"%@",[userInformation valueForKey:@"realName"]]);
    }else{
        nameLable.text = @"无名";
    }
    
    nameLable.font = [UIFont boldSystemFontOfSize:36];
    nameLable.textColor = UIColorFromRGB(0x0569a2);
    nameLable.backgroundColor = [UIColor clearColor];
    UIImageView *moneyImage =[[UIImageView alloc]initWithFrame:CGRectMake(40, 90, 50,50)];
    moneyImage.image =[UIImage imageNamed:@"moneyTitle"];
    balanceLable =[[UILabel alloc]initWithFrame:CGRectMake(125, 90, 400, 50)];
    balanceLable.text = [NSString stringWithFormat:@"账户余额:%@",[accountDic valueForKey:@"availableBalance"]];
    balanceLable.textColor = UIColorFromRGB(0x0569a2);
    balanceLable.font =[UIFont systemFontOfSize:26];
    
    balanceLable.backgroundColor = [UIColor clearColor];
    //    userHeadImage = [[UIImageView alloc]initWithFrame:CGRectMake(230, 15, 65, 50)];
    //top@2x
    UIButton *rightBtn1 = [[UIButton alloc]initWithFrame:CGRectMake(540, 10, 170, 70)];
    [rightBtn1 setBackgroundImage:[UIImage imageNamed:@"btnRight1"] forState:UIControlStateNormal];
    [rightBtn1 setTitle:@"划入" forState:UIControlStateNormal];
    rightBtn1.titleLabel.font = [UIFont systemFontOfSize:24];
    [rightBtn1 addTarget:self action:@selector(rightBtn1Click:) forControlEvents:UIControlEventTouchUpInside];
    UIButton *rightBtn2 = [[UIButton alloc]initWithFrame:CGRectMake(540, 90, 170, 70)];
    [rightBtn2 setTitle:@"划出" forState:UIControlStateNormal];
    [rightBtn2 addTarget:self action:@selector(rightBtn2Click:) forControlEvents:UIControlEventTouchUpInside];
    [rightBtn2 setBackgroundImage:[UIImage imageNamed:@"btnRight1"] forState:UIControlStateNormal];
    rightBtn2.titleLabel.font = [UIFont systemFontOfSize:24];
    [topImage addSubview:rightBtn2];
    [topImage addSubview:rightBtn1];
    [topImage addSubview:nameLable];
    topImage.userInteractionEnabled = YES;
    [topImage addSubview:balanceLable];
    [topImage addSubview:moneyImage];
    [self.view addSubview:topImage];
    
    [self contentView];
    
    [self footView];
}
//内容视图
-(void)contentView{
    
    moreView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 174+Y, SCREEN_WIDTH, SCREEN_HEIGHT-194)];
    if (SCREEN_HEIGHT>1024) {
        
        moreView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-128);
    }else{
        
        moreView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-108+60);
    }
    moreView.showsVerticalScrollIndicator = NO;
    accountMangeView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 174+Y, SCREEN_WIDTH, SCREEN_HEIGHT-129)];
    accountMangeView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-20-108+40);
    accountMangeView.showsVerticalScrollIndicator = NO;
    proView = [[UIView alloc]initWithFrame:CGRectMake(0, 174+Y, SCREEN_WIDTH, SCREEN_HEIGHT-160)];
    
    myAccountView = [[UIView alloc]initWithFrame:CGRectMake(0, 174+Y, SCREEN_WIDTH, SCREEN_HEIGHT-150)];
    contentScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 95, SCREEN_WIDTH, SCREEN_HEIGHT-240+41-10)];
    contentScroll.delegate = self;
    contentScroll.tag =300;
    contentScroll.contentSize = CGSizeMake(SCREEN_WIDTH*2, contentScroll.frame.size.height);
    contentScroll.pagingEnabled = YES;
    contentScroll.bounces = NO;
    pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-240+41-10+50, SCREEN_WIDTH, 10)];
    pageControl.numberOfPages = 2;
    [pageControl addTarget:self action:@selector(pageChanged:) forControlEvents:UIControlEventValueChanged];
    pageControl.backgroundColor = [UIColor redColor];
    
    UIImageView *choseView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 100)];
    choseView.image = [UIImage imageNamed:@"topInformation"];
    for (int i = 0; i<3; i++) {
        
        UIButton *choseBtn = [UIButton new];
        UIImageView *imageBtn = [UIImageView new];
        choseBtn.tag=10+i;
        [choseBtn addTarget:self action:@selector(chsoeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        NSArray *choseArray = [[NSArray alloc]initWithObjects:@"募资进度",@"项目期限",@"担保公司", nil];
        [choseBtn setTitle:[choseArray objectAtIndex:i] forState:UIControlStateNormal];
        choseBtn.titleLabel.font = [UIFont systemFontOfSize:30];
        [choseBtn setTintColor:UIColorFromRGB(0xffffff)];
        if (i==0) {
            choseBtn.frame = CGRectMake(0, 0,256,90);
            imageBtn.frame = CGRectMake(210, 40, 18, 10);
            imageBtn.image = [UIImage imageNamed:@"jianTou1"];
            [choseBtn setBackgroundImage:[UIImage imageNamed:@"xqBtnImage"] forState:UIControlStateNormal];
            imageBtn.tag =997;
            [choseBtn addSubview:imageBtn];
            
        }else {
            imageBtn.frame = CGRectMake(210, 40, 18, 10);
            imageBtn.image = [UIImage imageNamed:@"jianTou2"];
            [choseBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [choseBtn addSubview:imageBtn];
            imageBtn.tag = 997+i;
            [choseBtn setBackgroundImage:[UIImage imageNamed:@"btnbg"] forState:UIControlStateNormal];
            choseBtn.frame = CGRectMake(256+256*(i-1), 0,256,90);
        }
        
        //添加两个tableview tag 20 21;
        if (i<2) {
            contentTableView = [[UITableView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*i, 0, SCREEN_WIDTH, SCREEN_HEIGHT-Y-174-200)];
            contentTableView.tag = 20+i;
            contentTableView.delegate = self;
            contentTableView.dataSource = self;
            contentTableView.userInteractionEnabled = YES;
            __weak MYRecommendViewController *weakSelf = self;
            [contentTableView addPullToRefreshWithActionHandler:^{
                [weakSelf insertRowAtTop];
            }];
            [contentTableView addInfiniteScrollingWithActionHandler:^{
                [weakSelf insertAtBottom];
            }];
            contentTableView.separatorStyle=NO;
            [contentScroll addSubview:contentTableView];
        }
        
        [choseView addSubview:choseBtn];
    }
    [proView addSubview:contentScroll];
    proView.userInteractionEnabled = YES;
    [proView addSubview:pageControl];
    choseView.userInteractionEnabled = YES;
    //获取首页数据
    if (finishProArr==nil||unFinishProArr==nil) {
        mbHud = [[MBProgressHUD alloc] initWithView:self.view];
        mbHud.labelText = @"正在加载";
        [[self.view viewWithTag:20] addSubview:mbHud];
        mbHud.delegate = self;
        [mbHud show:YES];
        //获取项目列表
        strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1"];
        strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1"];
        [[MYWebService new]getDataAsynWithKey:key encryptedString:strIndexTrade1 appKey:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getdata:)   name:@"getAsyData" object:nil];
    }
    
    
    [proView addSubview:choseView];
    [self.view addSubview:proView];
    [self recordView];
    [self accountView];
    
}

//账户管理视图
-(void)accountView{
    int m =  [userRole integerValue];//11经纪人  12 投资人；
    for (int i = 0; i<7; i++) {
        UIButton *mangerBtn =[[UIButton alloc]initWithFrame:CGRectMake(20, 40+100*i, 728, 80)];
        UIImageView *rigthImageView =[[UIImageView alloc]initWithFrame:CGRectMake(690, 30, 20, 20)];
        rigthImageView.image = [UIImage imageNamed:@"btnRight@2x.png"];
        UIImageView *leftImageView =[[UIImageView alloc]initWithFrame:CGRectMake(60, 15, 50, 50)];
        if (i<5) {
            leftImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"manger@2x-%d.png",i+6]];
            mangerBtn.tag = 5+i;
            [mangerBtn setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"leftManage@2x-0%d.png",i+1]] forState:UIControlStateNormal];
        }else if(i==5){
            leftImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"left@2x-0%d.png",i+4]];
            [mangerBtn setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"myAccount@2x-0%d.png",i]] forState:UIControlStateNormal];
            mangerBtn.tag=100;
        }else if (i==6){
            [mangerBtn setBackgroundImage:[UIImage imageNamed:@"shiming"] forState:UIControlStateNormal];
            mangerBtn.tag = 101;
        }
        UILabel *titleLable =[[UILabel alloc]initWithFrame:CGRectMake(130, 20, 300, 40)];
        NSArray *titleArray = [[NSArray alloc]initWithObjects:@"佣金管理",@"投资人管理",@"修改登录或支付密码",@"绑定或修改手机",@"投资人开户",@"我的银行卡",@"实名认证", nil];
        titleLable.text = [titleArray objectAtIndex:i];
        titleLable.textColor = UIColorFromRGB(0x151515);
        titleLable.backgroundColor = [UIColor clearColor];
        titleLable.font=[UIFont systemFontOfSize:24];
        [mangerBtn addSubview:titleLable];
        [mangerBtn addSubview:leftImageView];
        [mangerBtn addSubview:rigthImageView];
        [mangerBtn addTarget:self action:@selector(accountMangerClick:) forControlEvents:UIControlEventTouchUpInside];
        if (m==12&&i>1&&i!=4) {
            [accountMangeView addSubview:mangerBtn];
            mangerBtn.frame = CGRectMake(20, 40+100*(i-2), 728, 80);
            if (i>3) {
                mangerBtn.frame = CGRectMake(20, 40+100*(i-3), 728, 80);
            }
        }else if(m==11){
            [accountMangeView addSubview:mangerBtn];
            if (i>1&&i<5&&i!=4) {
                mangerBtn.frame = CGRectMake(20, 40+100*(i+1), 728, 80);
            }else if (i==4){
                
                mangerBtn.frame = CGRectMake(20, 40+100*(i-2), 728, 80);
            }
        }
    }
    
    [self.view addSubview:accountMangeView];
    accountMangeView.hidden = YES;
    [self moreView];
}
//更多视图
-(void)moreView{
    NSArray *titleArray = [[NSArray alloc]initWithObjects:@"消息推送",@"通知列表",@"给我评分",@"帮助中心",@"反馈",@"关于我们",@"注销", nil];
    for (int i = 0; i<7; i++) {
        UIButton *moreBtn =[[UIButton alloc]initWithFrame:CGRectMake(20, 40+100*i, 728, 80)];
        UIImageView *rigthImageView =[[UIImageView alloc]initWithFrame:CGRectMake(690, 30, 20, 20)];
        rigthImageView.image = [UIImage imageNamed:@"btnRight@2x.png"];
        moreBtn.tag = 30+i;
        UILabel *titleLable =[[UILabel alloc]initWithFrame:CGRectMake(20, 20, 688, 40)];
        titleLable.font=[UIFont systemFontOfSize:24];
        titleLable.text = [titleArray objectAtIndex:i];
        titleLable.backgroundColor = [UIColor clearColor];
        [moreBtn addSubview:titleLable];
        if (i<6) {
            [moreBtn addSubview:rigthImageView];
            titleLable.textColor = UIColorFromRGB(0x151515);
            [moreBtn setBackgroundImage:[UIImage imageNamed:@"das@2x-02.png"] forState:UIControlStateNormal];
        }else if(i==6){
            titleLable.textColor = UIColorFromRGB(0xffffff);
            moreBtn.backgroundColor =UIColorFromRGB(0xe86e57);
            titleLable.textAlignment = NSTextAlignmentCenter;
            
        }
        [moreBtn addTarget:self action:@selector(moreBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [moreView addSubview:moreBtn];
    }
    moreView.hidden = YES;
    [self.view addSubview:moreView];
    [self.view addSubview:mbHud];
    
}

//交易记录
-(void)recordView{
    int m = [userRole integerValue];
    NSLog(@"m-----------%d",m);
    recordScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 80, SCREEN_WIDTH, SCREEN_HEIGHT-240+41)];
    recordScroll.delegate = self;
    recordScroll.contentSize = CGSizeMake(SCREEN_WIDTH*3, contentScroll.frame.size.height);
    recordScroll.pagingEnabled = YES;
    recordScroll.bounces = NO;
    recordScroll.tag=200;
    recordScroll.showsVerticalScrollIndicator = NO;
    //选项卡视图
    //    UIView *choseView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
    //    choseView.backgroundColor = UIColorFromRGB(0xb70100);
    UIImageView *choseView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    choseView.image = [UIImage imageNamed:@"titile_bg"];
    UIImageView *choseImage =[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH-20, 60)];
    choseImage.image = [UIImage imageNamed:@"chose_01@2x.png"];
    NSArray *choseArray = [[NSArray alloc]initWithObjects:@"投资记录",@"划入记录",@"划出记录", nil];
    for (int i = 0; i<3; i++) {
        UIButton *choseBtn = [[UIButton alloc]initWithFrame:CGRectMake(7.5+244*i, 4, 244, 52)];
        choseBtn.tag=110+i;
        [choseBtn addTarget:self action:@selector(recordBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [choseBtn setTitle:[choseArray objectAtIndex:i] forState:UIControlStateNormal];
        choseBtn.titleLabel.font=[UIFont systemFontOfSize:24];
        [choseBtn setTintColor:UIColorFromRGB(0xffffff)];
        recordTable = [[UITableView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH*i, 0, SCREEN_WIDTH, SCREEN_HEIGHT-Y-174-80-115)];
        recordTable.tag = 22+i;
        recordTable.delegate = self;
        recordTable.dataSource = self;
        //        [recordTable setSeparatorStyle:UITableViewCellSeparatorStyleSingleLineEtched];
        __weak MYRecommendViewController *weakSelf = self;
        [recordTable addInfiniteScrollingWithActionHandler:^{
            [weakSelf insertAtBottom];
        }];
        [recordTable addPullToRefreshWithActionHandler:^{
            [weakSelf insertRowAtTop];
        }];
        if (i==0) {
            [choseBtn setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
            
        }
        if(m==11&&i>0){
            if (i==1) {
                [choseBtn setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
            }
            recordScroll.contentSize = CGSizeMake(SCREEN_WIDTH*2, contentScroll.frame.size.height);
            choseBtn.frame =CGRectMake(7.5+244*(i-1), 4, 244, 52);
            recordTable.frame =CGRectMake(SCREEN_WIDTH*(i-1), 0, SCREEN_WIDTH, SCREEN_HEIGHT-Y-174-80-115);
            choseImage.frame = CGRectMake(130, 10, 508, 60);
            [recordScroll addSubview:recordTable];
            [choseImage addSubview:choseBtn];
            
        }else if (m==12){
            [recordScroll addSubview:recordTable];
            [choseImage addSubview:choseBtn];
        }
        
    }
    
    choseView.userInteractionEnabled = YES;
    choseImage.userInteractionEnabled = YES;
    [myAccountView addSubview:recordScroll];
    [choseView addSubview:choseImage];
    [myAccountView addSubview:choseView];
    myAccountView.hidden =YES;
    [self.view addSubview:myAccountView];
    
}

//底部视图）
-(void)footView{
    
    int j = 20;
    if(IOS_VERSION>=7.0){
        j = 0;
        
        
    }
    UIView *footView =[[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-115-j, SCREEN_WIDTH, 115)];
    UIImageView *footImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 115)];
    footImageView.image =[UIImage imageNamed:@"footImage@2x.png"];
    [footView addSubview:footImageView];
    for (int i =0; i<4; i++) {
        UIButton *footBtn =[[UIButton alloc]initWithFrame:CGRectMake(56+192*i, 2, 80, 80)];
        footBtn.tag = 40+i;
        footBtn.userInteractionEnabled = YES;
        UILabel *footLable =[[UILabel alloc]initWithFrame:CGRectMake(46+192*i, 82, 100, 20)];
        
        footLable.textColor = UIColorFromRGB(0xb70111);
        NSArray *footLableText =[[NSArray alloc]initWithObjects:@"推荐项目", @"交易记录",@"账户管理",@"更多",nil];
        footLable.text = [footLableText objectAtIndex:i];
        footLable.textColor = [UIColor redColor];
        footLable.font = [UIFont systemFontOfSize:24];
        footLable.backgroundColor = [UIColor clearColor];
        footLable.textAlignment=NSTextAlignmentCenter;
        //footLable.textColor = UIColorFromRGB(0xffffff);
        if (i==3) {
            footLable.frame = CGRectMake(46+192*i, 82, 100, 20);          }
        switch (i) {
            case 0:
                [footBtn setImage:[UIImage
                                   imageNamed:@"project_high.png"]
                         forState:UIControlStateNormal];
                break;
            case 1:
                [footBtn setImage:[UIImage
                                   imageNamed:@"account_nor.png"]
                         forState:UIControlStateNormal];
                break;
            case 2:
                [footBtn setImage:[UIImage
                                   imageNamed:@"accountManager_nor"]
                         forState:UIControlStateNormal];
                
                break;
            case 3:
                [footBtn setImage:[UIImage
                                   imageNamed:@"more"]
                         forState:UIControlStateNormal];
                break;
            default:
                break;
        }
        
        [footView addSubview:footBtn];
        [footView addSubview:footLable];
    }
    //添加四个透明btn覆盖地步lable和btn 解决点击范围小的问题
    for (int i = 0; i<4; i++) {
        UIButton *bigBtn = [[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/4*i, 0, SCREEN_WIDTH/4, 115)];
        bigBtn.backgroundColor = [UIColor clearColor];
        bigBtn.tag = 50+i;
        [bigBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [footView addSubview:bigBtn];
        bigBtn.userInteractionEnabled = YES;
        [footView addSubview:bigBtn];
        
    }
    [self.view addSubview:footView];
    
}
-(void)getdata:(NSNotification *)asyData{
    if (asyData!=nil) {
        unFinishProArr = [[JsonParse new] proListPerse:[asyData object]];
        strIndexTrade2 = @"service=indexTrade&tradeType=2&pageSize=10&pageNo=1";
        finishProArr = [[JsonParse new] proListPerse:[[MYWebService new] getDataSynWithKey:key encryptedString:strIndexTrade2 appKey:nil]];
        [(UITableView *)[self.view viewWithTag:20] reloadData];
        [(UITableView *)[self.view viewWithTag:21] reloadData];
        sleep(2);
        [mbHud removeFromSuperview];
        mbHud = nil;
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    }else if (unFinishProArr==nil||finishProArr==nil){
        
        [mbHud removeFromSuperview];
        mbHud = nil;
        [[NSNotificationCenter defaultCenter] removeObserver:self];
        
        UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"网络连接失败" message:@"请重新连接" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [myAlert show];
        
        
    }
    
}
-(void)insertRowAtTop{
    int64_t delayInSeconds = 2.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    //回到主线程更新数据，关闭动画
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        asyRequest = [MYWebService new];
        asyRequest.delegate = self;
        NSDateFormatter *dateformater=[NSDateFormatter new];
        [dateformater setDateFormat:@"yyyy-MM-dd"];
        NSString *priousDate = [dateformater stringFromDate:[[NSDate new] getPriousDateFromDate:[NSDate date] withMonth:-3]];//获取当前时间的前三月时间
        NSString *now=[dateformater stringFromDate:[NSDate date]];
        //投资记录
        NSString *strInverstRecordService=[NSString stringWithFormat:@"service=inverstRecordService&pageNo=1&pageSize=10&startDate=%@&endDate=%@",priousDate,now];
        //划入记录
        NSString *strDeductRecordService=[NSString stringWithFormat:@"service=deductRecordService&startDate=%@&endDate=%@&pageNo=1&pageSize=10",priousDate,now];
        NSString *strWithdrawasRecordService=[NSString stringWithFormat:@"service=withdrawasRecordService&startDate=2013-12-23&endDate=2014-02-17&pageNo=1&pageSize=10"];
        switch (indexTag) {
            case 0:{
                [self httpGetData:1 ];
                [((UITableView *)[self.view viewWithTag:20]).pullToRefreshView stopAnimating];
            }
                break;
            case 1:{
                [self httpGetData:1 ];
                [((UITableView *)[self.view viewWithTag:21]).pullToRefreshView stopAnimating];
            }
                break;
            case 2:{
                if ([userRole integerValue]==11) {
                    pageNo4 = 1;
                    [asyRequest getHuaRuAsynWithKey:key encryptedString:strDeductRecordService appKey:appKey];
                    [((UITableView *)[self.view viewWithTag:23]).pullToRefreshView stopAnimating];
                }else if ([userRole integerValue]==12){
                    pageNo3=1;
                    [asyRequest getTouZiAsynWithKey:key encryptedString:strInverstRecordService appKey:appKey];
                    [((UITableView *)[self.view viewWithTag:22]).pullToRefreshView stopAnimating];
                }
            }
                break;
            case 3:{
                [self httpGetData:1 ];
                if ([userRole integerValue]==11) {
                    pageNo5=1;
                    [asyRequest getHuaChuAsynWithKey:key encryptedString:strWithdrawasRecordService appKey:appKey];
                    [((UITableView *)[self.view viewWithTag:24]).pullToRefreshView stopAnimating];
                }else if ([userRole integerValue]==12){
                    pageNo4=1;
                    [((UITableView *)[self.view viewWithTag:23]).pullToRefreshView stopAnimating];
                }
            }
                break;
            case 4:{
                pageNo5=1;
                [asyRequest getHuaChuAsynWithKey:key encryptedString:strWithdrawasRecordService appKey:appKey];
                [((UITableView *)[self.view viewWithTag:24]).pullToRefreshView stopAnimating];
            }
                break;
                
            default:
                break;
        }
        
    });
    
}
-(void)insertAtBottom{
    int64_t delayInSeconds = 2.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    //回到主线程更新数据，关闭动画
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        //代扣划入记录
        asyRequest = [MYWebService new];
        asyRequest.delegate = self;
        NSDateFormatter *dateformater=[NSDateFormatter new];
        [dateformater setDateFormat:@"yyyy-MM-dd"];
        NSString *priousDate = [dateformater stringFromDate:[[NSDate new] getPriousDateFromDate:[NSDate date] withMonth:-3]];//获取当前时间的前三月时间
        NSString *now=[dateformater stringFromDate:[NSDate date]];
        //投资记录
        //        NSString *strInverstRecordService=[NSString stringWithFormat:@"service=inverstRecordService&pageNo=%d&pageSize=10&startDate=%@&endDate=%@",pageNo3,priousDate,now];
        //        //划入记录
        //        NSString *strDeductRecordService=[NSString stringWithFormat:@"service=deductRecordService&startDate=%@&endDate=%@&pageNo=%d&pageSize=10",priousDate,now,pageNo4];
        //        NSString *strWithdrawasRecordService=[NSString stringWithFormat:@"service=withdrawasRecordService&startDate=2013-12-23&endDate=2014-02-17&pageNo=%d&pageSize=10",pageNo5];
        switch (indexTag) {
            case 0:{
                [self httpGetData:pageNo1 ];
                pageNo1++;
                [((UITableView *)[self.view viewWithTag:20]).infiniteScrollingView stopAnimating];
            }
                break;
            case 1:{
                
                [self httpGetData:pageNo2 ];
                [((UITableView *)[self.view viewWithTag:21]).infiniteScrollingView stopAnimating];
                pageNo2++;
            }
                break;
            case 2:{
                if ([userRole integerValue]==11) {
                    pageNo4++;
                    //划入记录
                    NSString *strDeductRecordService=[NSString stringWithFormat:@"service=deductRecordService&startDate=%@&endDate=%@&pageNo=%d&pageSize=10",priousDate,now,pageNo4];
                    [asyRequest getHuaRuAsynWithKey:key encryptedString:strDeductRecordService appKey:appKey];
                    [((UITableView *)[self.view viewWithTag:23]).infiniteScrollingView stopAnimating];
                }else if ([userRole integerValue]==12){
                    pageNo3++;
                    NSString *strInverstRecordService=[NSString stringWithFormat:@"service=inverstRecordService&pageNo=%d&pageSize=10&startDate=%@&endDate=%@",pageNo3,priousDate,now];
                    [asyRequest getTouZiAsynWithKey:key encryptedString:strInverstRecordService appKey:appKey];
                    [((UITableView *)[self.view viewWithTag:22]).infiniteScrollingView stopAnimating];
                }
            }
                break;
            case 3:{
                if ([userRole integerValue]==11) {
                    pageNo5++;
                    
                    NSString *strWithdrawasRecordService=[NSString stringWithFormat:@"service=withdrawasRecordService&startDate=2013-12-23&endDate=2014-02-17&pageNo=%d&pageSize=10",pageNo5];
                    NSLog(@"%@",strWithdrawasRecordService);
                    [asyRequest getHuaChuAsynWithKey:key encryptedString:strWithdrawasRecordService appKey:appKey];
                    [((UITableView *)[self.view viewWithTag:24]).infiniteScrollingView stopAnimating];
                }else if ([userRole integerValue]==12){
                    pageNo4++;
                    //划入记录
                    NSString *strDeductRecordService=[NSString stringWithFormat:@"service=deductRecordService&startDate=%@&endDate=%@&pageNo=%d&pageSize=10",priousDate,now,pageNo4];
                    [asyRequest getHuaRuAsynWithKey:key encryptedString:strDeductRecordService appKey:appKey];
                    [((UITableView *)[self.view viewWithTag:23]).infiniteScrollingView stopAnimating];
                }
            }
                break;
            case 4:{
                pageNo5++;
                NSString *strWithdrawasRecordService=[NSString stringWithFormat:@"service=withdrawasRecordService&startDate=2013-12-23&endDate=2014-02-17&pageNo=%d&pageSize=10",pageNo5];
                [asyRequest getHuaChuAsynWithKey:key encryptedString:strWithdrawasRecordService appKey:appKey];
                [((UITableView *)[self.view viewWithTag:23]).infiniteScrollingView stopAnimating];
                [((UITableView *)[self.view viewWithTag:24]).infiniteScrollingView stopAnimating];
                [((UITableView *)[self.view viewWithTag:22]).infiniteScrollingView stopAnimating];
            }
                break;
                
            default:
                break;
        }
        
    });
    
}

//记录选项卡点击事件
-(void)recordBtnClick:(UIButton *)sender{
    
    switch (sender.tag) {
        case 110:
            [(UIButton *)[self.view viewWithTag:110] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
            [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:nil forState:UIControlStateNormal];
            [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:nil forState:UIControlStateNormal];
            [recordScroll setContentOffset:CGPointMake(0, 0) animated:YES];
            break;
        case 111:
            if ([userRole integerValue]==11) {
                [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:nil forState:UIControlStateNormal];
                [recordScroll setContentOffset:CGPointMake(SCREEN_WIDTH*0, 0) animated:YES];
                
            }else if([userRole integerValue]==12){
                [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:110] setBackgroundImage:nil forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:nil forState:UIControlStateNormal];
                [recordScroll setContentOffset:CGPointMake(SCREEN_WIDTH*1, 0) animated:YES];
            }
            break;
        case 112:
            if ([userRole integerValue]==11) {
                [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:nil forState:UIControlStateNormal];
                [recordScroll setContentOffset:CGPointMake(SCREEN_WIDTH*1, 0) animated:YES];
            }else if([userRole integerValue]==12){
                [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:110] setBackgroundImage:nil forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:nil forState:UIControlStateNormal];
                [recordScroll setContentOffset:CGPointMake(SCREEN_WIDTH*2, 0) animated:YES];
            }
            break;
            
        default:
            break;
    }
    
    
    
    
}
//选项卡点击事件 TAG:10 11 12
-(void)chsoeBtnClick:(UIButton *)sender{
    if (viewBool ==NO) {
        //        shouYiView = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 256, 60)];
        dateView  = [[UIView alloc]initWithFrame:CGRectMake(256, 90, 256, 160)];
        companyView= [[UIView alloc]initWithFrame:CGRectMake(256*2, 90, 256, 80)];
        shouYiView = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 90, 120)];
        shouYiView.userInteractionEnabled = YES;
        dateView.userInteractionEnabled = YES;
        companyView.userInteractionEnabled = YES;
        shouYiView.layer.borderWidth = 1;
        shouYiView.layer.borderColor = [UIColor redColor].CGColor;
        dateView.layer.borderWidth = 1;
        dateView.layer.borderColor = [UIColor redColor].CGColor;
        companyView.layer.borderWidth = 1;
        companyView.layer.borderColor = [UIColor redColor].CGColor;
        
        for (int i=0; i<3; i++) {
            
            UIButton *shouYiBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 40*i, 256,40)];
            shouYiBtn.tag = 200+i;
            NSArray *titleBtn = [[NSArray alloc]initWithObjects:@"0~30%",@"30%~60%",@"60%以上",nil];
            [shouYiBtn setTitle:[titleBtn objectAtIndex:i] forState:UIControlStateNormal];
            shouYiBtn.titleLabel.font = [UIFont systemFontOfSize:20];
            [shouYiBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [shouYiBtn addTarget:self action:@selector(searchBtn:) forControlEvents:UIControlEventTouchUpInside];
            [shouYiView addSubview:shouYiBtn];
            shouYiView.backgroundColor = [UIColor whiteColor];
            [proView addSubview:shouYiView];
        }
        for (int i=0; i<4; i++) {
            UIButton *dateBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 40*i, 256,40 )];
            dateBtn.tag = 203+i;
            NSArray *titleBtn = [[NSArray alloc]initWithObjects:@"1-3月期",@"3-6月期",@"6-9月期",@"9-12月期",nil];
            [dateBtn setTitle:[titleBtn objectAtIndex:i] forState:UIControlStateNormal];
            dateBtn.titleLabel.font = [UIFont systemFontOfSize:20];
            [dateBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [dateBtn addTarget:self action:@selector(searchBtn:) forControlEvents:UIControlEventTouchUpInside];
            dateView.backgroundColor = [UIColor whiteColor];
            [dateView addSubview:dateBtn];
            [proView addSubview:dateView];
            
        }
        for (int i=0; i<2; i++) {
            UIButton *companyBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 40*i, 256,40 )];
            companyBtn.tag = 208+i;
            NSArray *titleBtn = [[NSArray alloc]initWithObjects:@"渝台担保",@"教育担保",nil];
            [companyBtn setTitle:[titleBtn objectAtIndex:i] forState:UIControlStateNormal];
            companyBtn.titleLabel.font = [UIFont systemFontOfSize:20];
            [companyBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [companyBtn addTarget:self action:@selector(searchBtn:) forControlEvents:UIControlEventTouchUpInside];
            [companyView addSubview:companyBtn];
            [proView addSubview:companyView];
            companyView.backgroundColor = [UIColor whiteColor];
        }
        shouYiView.hidden = NO;
        dateView.hidden = YES;
        companyView.hidden = YES;
        viewBool = YES;
        
    }
    
    switch (sender.tag) {
        case 10:{
            isOpen2=NO;
            isOpen3=NO;
            if (isOpen1 == NO) {
                shouYiView.hidden = NO;
                isOpen1=YES;
            }else if(isOpen1 == YES){
                shouYiView.hidden = YES;
                isOpen1 = NO;
            }
            dateView.hidden = YES;
            companyView.hidden = YES;
            [sender setBackgroundImage:[UIImage imageNamed:@"xqBtnImage"] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:11]) setBackgroundImage:[UIImage imageNamed:@"btnbg"] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:12]) setBackgroundImage:[UIImage imageNamed:@"btnbg"] forState:UIControlStateNormal];
            [sender setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:11]) setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:12]) setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            ((UIImageView *)[self.view viewWithTag:997]).image = [UIImage imageNamed:@"jianTou1"];
            ((UIImageView *)[self.view viewWithTag:998]).image = [UIImage imageNamed:@"jianTou2"];
            ((UIImageView *)[self.view viewWithTag:999]).image = [UIImage imageNamed:@"jianTou2"];
        }
            
            break;
        case 11:{
            isOpen1=NO;
            isOpen3=NO;
            if (isOpen2 == NO) {
                dateView.hidden = NO;
                isOpen2=YES;
            }else if(isOpen2 == YES){
                dateView.hidden = YES;
                isOpen2 = NO;
            }
            
            shouYiView.hidden = YES;
            companyView.hidden = YES;
            [sender setBackgroundImage:[UIImage imageNamed:@"xqBtnImage"] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:10]) setBackgroundImage:[UIImage imageNamed:@"btnbg"] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:12]) setBackgroundImage:[UIImage imageNamed:@"btnbg"] forState:UIControlStateNormal];
            [sender setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:10]) setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:12]) setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            ((UIImageView *)[self.view viewWithTag:997]).image = [UIImage imageNamed:@"jianTou2"];
            ((UIImageView *)[self.view viewWithTag:998]).image = [UIImage imageNamed:@"jianTou1"];
            ((UIImageView *)[self.view viewWithTag:999]).image = [UIImage imageNamed:@"jianTou2"];
        }
            
            
            
            break;
        case 12:{
            isOpen1=NO;
            isOpen2=NO;
            if (isOpen3 == NO) {
                companyView.hidden = NO;
                isOpen3=YES;
            }else if(isOpen3 == YES){
                companyView.hidden = YES;
                isOpen3 = NO;
            }
            
            shouYiView.hidden = YES;
            dateView.hidden = YES;
            [sender setBackgroundImage:[UIImage imageNamed:@"xqBtnImage"] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:11]) setBackgroundImage:[UIImage imageNamed:@"btnbg"] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:10]) setBackgroundImage:[UIImage imageNamed:@"btnbg"] forState:UIControlStateNormal];
            [sender setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:11]) setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [((UIButton *)[self.view viewWithTag:10]) setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            ((UIImageView *)[self.view viewWithTag:997]).image = [UIImage imageNamed:@"jianTou2"];
            ((UIImageView *)[self.view viewWithTag:998]).image = [UIImage imageNamed:@"jianTou2"];
            ((UIImageView *)[self.view viewWithTag:999]).image = [UIImage imageNamed:@"jianTou1"];
        }
            
            
            break;
            
        default:
            break;
    }
    
    
}
//我的账户点击事件 tag:13 14 15 16
-(void)accountClick:(UIButton *)sender{
    switch (sender.tag) {
            
        case 13:
        {
            //操作页面
            userAccount *userInformation=[userAccount new];
            [self presentViewController:userInformation animated:NO completion:nil];
            
        }
            break;
            
        case 14:
        {
            //操作页面
            MYOperateViewController *operateVC=[MYOperateViewController new];
            [self presentViewController:operateVC animated:NO completion:nil];
            
        }
            break;
        case 15:
            //            [self presentViewController:[TouZiRecordViewController new] animated:NO completion:nil];
            break;
            
        case 16:
        {
            //我的银行卡页面
            MYCardTableViewController *myCardsVC=[MYCardTableViewController new];
            [self presentViewController:myCardsVC animated:NO completion:nil];
            
            
        }
            break;
            
        default:
            break;
    }
    
}
//账户管理点击事件 tag 5 6 7 8 9
-(void)accountMangerClick:(UIButton *)sender{
    switch (sender.tag) {
        case 5:
        {
            //佣金管理
            [self presentViewController:[MYStatisticsViewController new] animated:YES completion:nil];
        }
            
        case 6:
        {
            //投资人管理页面
            MYInvestorListsViewController *investorListsVC=[MYInvestorListsViewController new];
            [self presentViewController:investorListsVC animated:YES completion:nil];
        }
            break;
        case 7:
        {
            //修改密码页面
            MYChangePdViewController *changePdVC=[MYChangePdViewController new];
            [self presentViewController:changePdVC animated:YES completion:nil];
        }
            break;
            
        case 8:
        {
            //修改电话
            [self presentViewController:[MYChangePhoneNoViewController new] animated:YES completion:nil];
        }
            break;
        case 9:
        {
            //投资人开户
            [self presentViewController:[MYAgentCreated new] animated:YES completion:nil];
        }
            break;
        case 100:{
            
            //我的银行卡页面
            MYCardTableViewController *myCardsVC=[MYCardTableViewController new];
            [self presentViewController:myCardsVC animated:NO completion:nil];
        }
            break;
        case 101:{
            
            //实名认证
            MYPersonalInfoViewController *certifiedVC=[MYPersonalInfoViewController new];
            [self presentViewController:certifiedVC animated:NO completion:nil];
        }
            break;
        default:
            break;
    }
    
}
//更多页面点击事件 tag  30 31 32 33 34 35 36
-(void)moreBtnClick:(UIButton *)sender{
    
    switch (sender.tag) {
        case 30:
            break;
        case 31:
        {
            [self presentViewController:[notifactionView new] animated:YES completion:nil];
        }
            break;
        case 32:{
            
            
            //    NSString *str = [NSString stringWithFormat:
            //     @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",appID]; //appID 解释如下
            //   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
        }
            
            
            break;
        case 33:
        {
            //帮助页面
            MYHelpViewController *helpVC=[MYHelpViewController new];
            [self presentViewController:helpVC animated:YES completion:nil];
        }
            break;
        case 34:
        {
            //反馈页面
            MYFeedbackViewController *feedbackVC=[MYFeedbackViewController new];
            [self presentViewController:feedbackVC animated:YES completion:nil];
        }
            break;
            
        case 35:
        {
            //关于页面
            MYAboutViewController *aboutVC=[MYAboutViewController new];
            [self presentViewController:aboutVC animated:YES completion:nil];
            
        }
            
            break;
            
        case 36:{
            loginDic=nil;
            loginFlag=false;
            userInformation=nil;
            [self presentViewController:[PubicView new] animated:YES completion:nil];
        }
            
            
            break;
        default:
            break;
    }
}

//搜索选项btn点击事件
-(void)httpGetData:(int)_pageNo{
    __block NSMutableArray *rsFinishArr = [NSMutableArray new];
    __block NSMutableArray *rsUnFinishArr = [NSMutableArray new];
    strIndexTrade1 = [strIndexTrade1 stringByReplacingOccurrencesOfString:@"pageNo=1" withString:[NSString stringWithFormat:@"pageNo=%d",_pageNo]];
    strIndexTrade2 = [strIndexTrade2 stringByReplacingOccurrencesOfString:@"pageNo=1" withString:[NSString stringWithFormat:@"pageNo=%d",_pageNo]];
    NSLog(@"-----------strIndexTrade1:%@",strIndexTrade1);
    NSLog(@"-----------strIndexTrade1:%@",strIndexTrade2);
    if (isScreen==YES) {
        mbHud = [[MBProgressHUD alloc] initWithView:self.view];
        mbHud.labelText = @"正在查询";
        [self.view addSubview:mbHud];
        mbHud.delegate = self;
        asyRequest = [MYWebService new];
        asyRequest.delegate = self;
        [mbHud show:YES];
        [asyRequest getUnfinishAsynWithKey:key encryptedString:strIndexTrade1 appKey:appKey];
        [asyRequest getProFinishAsynWithKey:key encryptedString:strIndexTrade2 appKey:appKey];
        
    }else {
        switch (indexTag) {
            case 0:
                rsUnFinishArr =  [[JsonParse new] proListPerse:[[MYWebService new]getDataSynWithKey:key encryptedString:strIndexTrade1 appKey:nil]];
                if (_pageNo==1) {
                    unFinishProArr = rsUnFinishArr;
                }else{
                    [unFinishProArr addObjectsFromArray:rsUnFinishArr];
                }
                break;
            case 1:
                rsFinishArr =  [[JsonParse new] proListPerse:[[MYWebService new]getDataSynWithKey:key encryptedString:strIndexTrade2 appKey:nil]];
                if (_pageNo==1) {
                    finishProArr = rsFinishArr;
                }else {
                    [finishProArr addObjectsFromArray:rsFinishArr];
                }
                break;
                
            default:
                break;
        }
        [(UITableView *)[self.view viewWithTag:20] reloadData];
        [(UITableView *)[self.view viewWithTag:21] reloadData];
    }
    isScreen=NO;
}
-(void)searchBtn:(UIButton *)sender{
    isScreen = YES;
    switch (sender.tag) {
        case 200:{
            starRate = @"0";
            endRate = @"30";
            shouYiView.hidden = YES;
            isOpen1 = NO;
            strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1M&startRate=%@&endRate=%@",starRate,endRate];
            strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1M&startRate=%@&endRate=%@",starRate,endRate];
            [self httpGetData:1 ];
            
        }
            break;
        case 201:
            starRate = @"30";
            endRate = @"60";
            strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1M&startRate=%@&endRate=%@",starRate,endRate];
            strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1M&startRate=%@&endRate=%@",starRate,endRate];
            shouYiView.hidden = YES;
            isOpen1 = NO;
            [self httpGetData:1];
            
            break;
            
        case 202:
            starRate = @"60";
            endRate = @"100";
            strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1&startRate=%@&endRate=%@",starRate,endRate];
            strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1&startRate=%@&endRate=%@",starRate,endRate];
            shouYiView.hidden = YES;
            isOpen1 = NO;
            [self httpGetData:1];
            break;
            
        case 203:
            starTime = @"1";
            endTime = @"3";
            strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            dateView.hidden = YES;
            isOpen2 = NO;
            [self httpGetData:1];
            break;
            
        case 204:
            starTime = @"3";
            endTime = @"6";
            strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            dateView.hidden = YES;
            isOpen2 = NO;
            [self httpGetData:1];
            break;
        case 205:
            starTime = @"6";
            endTime = @"9";
            strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            dateView.hidden = YES;
            isOpen2 = NO;
            [self httpGetData:1];
            break;
        case 206:
            starTime = @"9";
            endTime = @"12";
            strIndexTrade1 = [NSString stringWithFormat:@"service=indexTrade&tradeType=1&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            strIndexTrade2 = [NSString stringWithFormat:@"service=indexTrade&tradeType=2&pageSize=10&pageNo=1&startTime=%@&endTime=%@",starTime,endTime];
            dateView.hidden = YES;
            isOpen2 = NO;
            [self httpGetData:1];
            break;
        case 208:
            companyView.hidden = YES;
            isOpen3 = NO;
            strIndexTrade1 = @"service=indexTrade&tradeType=1&pageSize=10&pageNo=1&guarantee=YT";
            strIndexTrade2 = @"service=indexTrade&tradeType=2&pageSize=10&pageNo=1&guarantee=YT";
            [self httpGetData:1];
            break;
        case 209:
            companyView.hidden = YES;
            isOpen3 = NO;
            strIndexTrade1 = @"service=indexTrade&tradeType=1&pageSize=10&pageNo=1&guarantee=EDU";
            strIndexTrade2 = @"service=indexTrade&tradeType=2&pageSize=10&pageNo=1&guarantee=EDU";
            [self httpGetData:1];
            break;
            
        default:
            break;
    }}
//底部btn点击事件 TAG :40 41 42 43
-(void)btnClick:(UIButton *)sender{
    switch (sender.tag) {
        case 50:
            [((UIButton*)[self.view viewWithTag:40]) setImage:[UIImage
                                                               imageNamed:@"project_high.png"]
                                                     forState:UIControlStateNormal];
            [((UIButton*)[self.view viewWithTag:41]) setImage:[UIImage
                                                               imageNamed:@"account_nor.png"]
                                                     forState:UIControlStateNormal];
            [((UIButton*)[self.view viewWithTag:42]) setImage:[UIImage
                                                               imageNamed:@"accountManager_nor"]
                                                     forState:UIControlStateNormal];
            [((UIButton*)[self.view viewWithTag:43]) setImage:[UIImage
                                                               imageNamed:@"more"]
                                                     forState:UIControlStateNormal];
            
            moreView.hidden = YES;
            myAccountView.hidden = YES;
            accountMangeView.hidden = YES;
            proView.hidden=NO;
            
            break;
        case 51:{
            indexTag = 2;
            //代扣划入记录
            asyRequest = [MYWebService new];
            asyRequest.delegate = self;
            NSDateFormatter *dateformater=[NSDateFormatter new];
            [dateformater setDateFormat:@"yyyy-MM-dd"];
            NSString *priousDate = [dateformater stringFromDate:[[NSDate new] getPriousDateFromDate:[NSDate date] withMonth:-3]];//获取当前时间的前三月时间
            NSString *now=[dateformater stringFromDate:[NSDate date]];
            //投资记录
            NSString *strInverstRecordService=[NSString stringWithFormat:@"service=inverstRecordService&pageNo=1&pageSize=10&startDate=%@&endDate=%@",priousDate,now];
            if ([userRole integerValue]==12&&arrtouzi==nil) {
                [asyRequest getTouZiAsynWithKey:key encryptedString:strInverstRecordService appKey:appKey];
            }
            
            //划入记录
            NSString *strDeductRecordService=[NSString stringWithFormat:@"service=deductRecordService&startDate=%@&endDate=%@&pageNo=1&pageSize=10",priousDate,now];
            if (arrhuaru==nil) {
                [asyRequest getHuaRuAsynWithKey:key encryptedString:strDeductRecordService appKey:appKey];
            }
            NSString *strWithdrawasRecordService=@"service=withdrawasRecordService&startDate=2013-12-23&endDate=2014-02-17&pageNo=1&pageSize=10";
            if (arrhuaru==nil) {
                [asyRequest getHuaChuAsynWithKey:key encryptedString:strWithdrawasRecordService appKey:appKey];
            }
            [((UIButton*)[self.view viewWithTag:40]) setImage:[UIImage
                                                               imageNamed:@"project_nor.png"]
                                                     forState:UIControlStateNormal];
            [((UIButton*)[self.view viewWithTag:41]) setImage:[UIImage
                                                               imageNamed:@"account_high.png"]
                                                     forState:UIControlStateNormal];
            [((UIButton*)[self.view viewWithTag:42]) setImage:[UIImage
                                                               imageNamed:@"accountManager_nor"]
                                                     forState:UIControlStateNormal];
            [((UIButton*)[self.view viewWithTag:43]) setImage:[UIImage
                                                               imageNamed:@"more"]
                                                     forState:UIControlStateNormal];
            moreView.hidden = YES;
            myAccountView.hidden = NO;
            accountMangeView.hidden = YES;
            proView.hidden=YES;
        }
            break;
        case 52:
            [(UIButton*)[self.view viewWithTag:40] setImage:[UIImage
                                                             imageNamed:@"project_nor.png"]
                                                   forState:UIControlStateNormal];
            [(UIButton*)[self.view viewWithTag:41] setImage:[UIImage
                                                             imageNamed:@"account_nor.png"]
                                                   forState:UIControlStateNormal];
            [(UIButton*)[self.view viewWithTag:42] setImage:[UIImage
                                                             imageNamed:@"accountManager_high.png"]
                                                   forState:UIControlStateNormal];
            [(UIButton*)[self.view viewWithTag:43] setImage:[UIImage
                                                             imageNamed:@"more"]
                                                   forState:UIControlStateNormal];
            moreView.hidden = YES;
            myAccountView.hidden = YES;
            accountMangeView.hidden = NO;
            proView.hidden=YES;
            break;
        case 53:
            [(UIButton*)([self.view viewWithTag:40]) setImage:[UIImage
                                                               imageNamed:@"project_nor.png"]
                                                     forState:UIControlStateNormal];
            [(UIButton*)([self.view viewWithTag:41]) setImage:[UIImage
                                                               imageNamed:@"account_nor.png"]
                                                     forState:UIControlStateNormal];
            [(UIButton*)[self.view viewWithTag:42] setImage:[UIImage
                                                             imageNamed:@"accountManager_nor"]
                                                   forState:UIControlStateNormal];
            [((UIButton*)[self.view viewWithTag:43]) setImage:[UIImage
                                                               imageNamed:@"more_on"]
                                                     forState:UIControlStateNormal];
            moreView.hidden = NO;
            myAccountView.hidden = YES;
            accountMangeView.hidden = YES;
            proView.hidden=YES;
            break;
        default:
            break;
    }
    
    
}
//----异步请求代理
-(void)proFinishRequest:(NSDictionary *)asyData{
    if (asyData!=nil) {
        [finishProArr removeAllObjects];
        finishProArr =  [[JsonParse new] proListPerse:asyData];
    }
    NSLog(@"异步请求完成的数据：--------%@",asyData);
    if (finishProArr.count!=0&&unFinishProArr.count!=0) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [(UITableView *)[self.view viewWithTag:20] reloadData];
            [(UITableView *)[self.view viewWithTag:21] reloadData];
            sleep(2);
            [mbHud removeFromSuperview];
        });
        
    }else{
        [mbHud removeFromSuperview];
    }
    
    
}
-(void)proUnfinishRequest:(NSDictionary *)asyData{
    NSLog(@"异步请求完成的数据：--------%@",asyData);
    
    if (asyData!=nil) {
        unFinishProArr =  [[JsonParse new] proListPerse:asyData];
    }
    
    if (finishProArr.count!=0&&unFinishProArr.count!=0) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [(UITableView *)[self.view viewWithTag:20] reloadData];
            [(UITableView *)[self.view viewWithTag:21] reloadData];
            sleep(2);
            [mbHud removeFromSuperview];
        });
        
    }else{
        [mbHud removeFromSuperview];
    }
}
-(void)finishTouZiRequest:(NSArray *)asyData{
    if (pageNo3==1) {
        arrtouzi = [NSMutableArray new];
        
        [arrtouzi addObjectsFromArray:asyData];
    }else if(pageNo3>1){
        [arrtouzi addObjectsFromArray:asyData];
    }
    [(UITableView *)[self.view viewWithTag:22] reloadData];
}
-(void)finishHuaRuRequest:(NSArray *)asyData{
    if (pageNo4==1) {
        arrhuaru = [NSMutableArray new];
        [arrhuaru addObjectsFromArray:asyData];
        NSLog(@"arrhuaRU---%d",arrhuaru.count);
    }else if(pageNo4>1){
        [arrhuaru addObjectsFromArray:asyData];
    }
    
    [(UITableView *)[self.view viewWithTag:23] reloadData];
    
}
-(void)finishHuaChuRequest:(NSArray *)asyData{
    if (pageNo5==1) {
        arrhuachu = [NSMutableArray new];
        [arrhuachu addObjectsFromArray:asyData];
    }else{
        [arrhuachu addObjectsFromArray:asyData];
    }
    
    [(UITableView *)[self.view viewWithTag:24] reloadData];
    
}
-(void)rightBtn1Click:(id)sender{
    
    ApplyTransferredinVC *transferInVC=[ApplyTransferredinVC new];
    [self presentViewController:transferInVC animated:NO completion:nil];
    //    [self presentModalViewController:transferInVC animated:NO];
    
    
    
}
-(void)rightBtn2Click:(id)sender{
    
    ApplyTransferredOutVC *transferOutVC=[ApplyTransferredOutVC new];
    [self presentViewController:transferOutVC animated:YES completion:nil];
    
    
}
//-(void)pageChanged:(UIPageControl *)sender{
//
//    int page = sender.currentPage;
//    [contentScroll setContentOffset:CGPointMake(320*page, 0) animated:YES];
//
//}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView.tag==200) {
        indexTag = scrollView.contentOffset.x/SCREEN_WIDTH+2;
        NSLog(@"----indexTag2-----%d",indexTag);
    }else if(scrollView.tag==300){
        indexTag = scrollView.contentOffset.x/SCREEN_WIDTH;
        NSLog(@"scroller con------%f",scrollView.contentOffset.x);
        NSLog(@"-----indexTag1----%d",indexTag);
    }
    
}
//当减速完毕，滚动视图停止时得到通知，收到这个通知的时刻。滚动视图的contentoffset属性会反映出滚动条最终停止的位置
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    if (scrollView.tag==200) {
        
        NSInteger index = fabs(scrollView.contentOffset.x)/scrollView.frame.size.width;
        switch (index) {
            case 0:
                if ([userRole integerValue]==11) {
                    [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                    [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:nil forState:UIControlStateNormal];
                }else if ([userRole integerValue]==12){
                    [(UIButton *)[self.view viewWithTag:110] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                    [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:nil forState:UIControlStateNormal];
                    [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:nil forState:UIControlStateNormal];
                }
                break;
            case 1:
                if ([userRole integerValue]==11) {
                    [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                    [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:nil forState:UIControlStateNormal];
                }else if ([userRole integerValue]==12){
                    [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                    [(UIButton *)[self.view viewWithTag:110] setBackgroundImage:nil forState:UIControlStateNormal];
                    [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:nil forState:UIControlStateNormal];
                }
                break;
            case 2:
                [(UIButton *)[self.view viewWithTag:112] setBackgroundImage:[UIImage imageNamed:@"chose_02@2x.png"] forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:110] setBackgroundImage:nil forState:UIControlStateNormal];
                [(UIButton *)[self.view viewWithTag:111] setBackgroundImage:nil forState:UIControlStateNormal];
                
                break;
                
            default:
                break;
                
        }
    }else{
        NSInteger index = fabs(scrollView.contentOffset.x)/scrollView.frame.size.width;
        [pageControl setCurrentPage:index];
    }
}
#pragma tableview dataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    int row= 0;
    switch (tableView.tag) {
        case 20:
            row =  unFinishProArr.count;
            NSLog(@"unfiish.Count%d",row);
            break;
        case 21:
            row =  finishProArr.count;
            break;
        case 22:
            row =  self.arrtouzi.count;
            break;
        case 23:
            row = self.arrhuaru.count;
            break;
        case 24:
            row = self.arrhuachu.count;
            break;
        default:
            break;
            
    }
    return row;
    
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [UITableViewCell new];
    switch (tableView.tag) {
        case 20:{
            static NSString *CellIdentifier = @"proCell";
            proCell *proCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (proCell == nil ) {
                NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"proCell" owner:self options:nil];
                proCell = [array objectAtIndex:0];
            }
            proCell.selectionStyle = UITableViewCellSelectionStyleNone;
            proCell.jinDuLable.text  = [[unFinishProArr objectAtIndex:indexPath.row] persontage];
            NSLog(@"jindu --------%@",proCell.jinDuLable.text);
            proCell.guaranteeLable.text = [[unFinishProArr objectAtIndex:indexPath.row] guaranteeName];
            proCell.xuQiuLable.text = [NSString stringWithFormat:@"%@元",[[unFinishProArr objectAtIndex:indexPath.row] tradeLoanedAmount]];
            proCell.proTitleLable.text = [NSString stringWithFormat:@"%@",[[unFinishProArr objectAtIndex:indexPath.row] tradeName]];
            NSLog(@"%@",proCell.proTitleLable.text);
            proCell.creatTimeLable.text = [NSString stringWithFormat:@"%@",[[unFinishProArr objectAtIndex:indexPath.row] investStartTime]];
            proCell.deadTimeLable.text = [NSString stringWithFormat:@"%@",[[unFinishProArr objectAtIndex:indexPath.row] deadline]];
            proCell.timeLbale.text = [[unFinishProArr objectAtIndex:indexPath.row] timePeriod];
            NSLog(@"TimeLable --------%@",proCell.timeLbale.text);
            proCell.yearRate.text = [NSString stringWithFormat:@"%@",[[unFinishProArr objectAtIndex:indexPath.row] tradeAnnualRate]];
            NSLog(@"年化收益 --------%@",proCell.yearRate.text);
            proCell.yiRongLable.text = [NSString stringWithFormat:@"%@元",[[unFinishProArr objectAtIndex:indexPath.row] tradeLoanedAmount]];
            proCell.haichaLable.text = [NSString stringWithFormat:@"%@元",[[unFinishProArr objectAtIndex:indexPath.row] requiredAmount]];
            proCell.stateLable.text = @"投资中";
            NSString *str = proCell.jinDuLable.text;
            NSRange rang1 =  [str rangeOfString:@"%"];
            float i = [proCell.jinDuLable.text substringToIndex:rang1.location].floatValue ;
            [proCell.progress setProgress:i/100 animated:YES];
            cell =proCell;
            
        }
            break;
        case 21:
        {
            static NSString *CellIdentifier = @"proCell";
            proCell *proCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (proCell == nil ) {
                NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"proCell" owner:self options:nil];
                proCell = [array objectAtIndex:0];
            }
            proCell.selectionStyle = UITableViewCellSelectionStyleNone;
            proCell.jinDuLable.text  = [[finishProArr objectAtIndex:indexPath.row] persontage];
            proCell.guaranteeLable.text = [[finishProArr objectAtIndex:indexPath.row] guaranteeName];
            proCell.xuQiuLable.text = [NSString stringWithFormat:@"%@元",[[finishProArr objectAtIndex:indexPath.row] tradeLoanedAmount]];
            proCell.proTitleLable.text = [NSString stringWithFormat:@"%@",[[finishProArr objectAtIndex:indexPath.row] tradeName]];
            NSLog(@"%@",proCell.proTitleLable.text);
            proCell.creatTimeLable.text = [NSString stringWithFormat:@"%@",[[finishProArr objectAtIndex:indexPath.row] investStartTime]];
            proCell.deadTimeLable.text = [NSString stringWithFormat:@"%@",[[finishProArr objectAtIndex:indexPath.row] deadline]];
            proCell.timeLbale.text = [[finishProArr objectAtIndex:indexPath.row] timePeriod];
            
            proCell.yearRate.text = [NSString stringWithFormat:@"%@",[[finishProArr objectAtIndex:indexPath.row] tradeAnnualRate]];
            proCell.yiRongLable.text = [NSString stringWithFormat:@"%@元",[[finishProArr objectAtIndex:indexPath.row] tradeLoanedAmount]];
            proCell.haichaLable.text = [NSString stringWithFormat:@"%@元",[[finishProArr objectAtIndex:indexPath.row] requiredAmount]];
            proCell.stateLable.text = @"已完成";
            NSString *str = proCell.jinDuLable.text;
            NSRange rang1 =  [str rangeOfString:@"%"];
            float i = [proCell.jinDuLable.text substringToIndex:rang1.location].floatValue ;
            [proCell.progress setProgress:i/100 animated:YES];
            cell =proCell;
        }
            
            break;
        case 22:{
            
            static NSString *CellIdentifier = @"recordCell";
            RecordCell *recordCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (recordCell == nil ) {
                NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"RecordCell" owner:self options:nil];
                recordCell = [array objectAtIndex:0];
            }
            recordCell.moneyLable.text =[NSString stringWithFormat:@"￥%@",[[self.arrtouzi objectAtIndex:indexPath.row] valueForKey:@"amount"]];
            recordCell.danbaoLable.text = [[self.arrtouzi objectAtIndex:indexPath.row] valueForKey:@"investflowCode"];
            recordCell.stateLable.text = [[self.arrtouzi objectAtIndex:indexPath.row] valueForKey:@"status"];
            NSDateFormatter *datefomatter=[NSDateFormatter new];
            [datefomatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSDate *date=[datefomatter dateFromString:[[self.arrtouzi objectAtIndex:indexPath.row] valueForKey:@"date"]];
            [datefomatter setDateFormat:@"yyyy-MM-dd "];
            NSString *strdate=[datefomatter stringFromDate:date];
            recordCell.dateLable.text = [NSString stringWithFormat:@"%@",strdate];
            cell = recordCell;
        }
            
            break;
        case 23:{
            
            static NSString *CellIdentifier = @"reuseIdentifier";
            TransforCell *transforCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (transforCell == nil ) {
                NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TransforCell" owner:self options:nil];
                transforCell = [array objectAtIndex:0];
            }
            
            transforCell.lblbusnessClass.text=[[self.arrhuaru objectAtIndex:indexPath.row] valueForKey:@"apiAccess"];
            
            NSDateFormatter *datefomatter=[NSDateFormatter new];
            [datefomatter setDateFormat:@"yyyy-MM-dd"];
            NSDate *date= [NSDate dateWithTimeIntervalSince1970:[[[self.arrhuaru objectAtIndex:indexPath.row] valueForKey:@"payTime"] longLongValue]/1000];
            NSString *strDate=[datefomatter stringFromDate:date];
            transforCell.lblDate.text=[NSString stringWithFormat:@"%@",strDate];
            transforCell.lblBusenessId.text=[NSString stringWithFormat:@"流水号：%@",[[self.arrhuaru objectAtIndex:indexPath.row] valueForKey:@"outBizNo"]];
            transforCell.lblState.text=[[self.arrhuaru objectAtIndex:indexPath.row] valueForKey:@"status"];
            transforCell.lblMoney.text=[NSString stringWithFormat:@"￥%@",[[self.arrhuaru objectAtIndex:indexPath.row] valueForKey:@"amount"]];
            
            cell = transforCell;
        }
            
            break;
        case 24:{
            
            static NSString *CellIdentifier = @"reuseIdentifier";
            TransforCell *transforCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (transforCell == nil ) {
                NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TransforCell" owner:self options:nil];
                transforCell = [array objectAtIndex:0];
            }
            
            transforCell.lblbusnessClass.text=[[self.arrhuachu objectAtIndex:indexPath.row] valueForKey:@"bankName"];
            NSDateFormatter *datefomatter=[NSDateFormatter new];
            [datefomatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSDate *date=[datefomatter dateFromString:[[self.arrhuachu objectAtIndex:indexPath.row] valueForKey:@"payTime"]];
            [datefomatter setDateFormat:@"yyyy-MM-dd "];
            NSString *strdate=[datefomatter stringFromDate:date];
            transforCell.lblDate.text=[NSString stringWithFormat:@"%@",strdate];
            transforCell.lblBusenessId.text=[NSString stringWithFormat:@"流水号：%@",[[self.arrhuachu objectAtIndex:indexPath.row] valueForKey:@"outBizNo"]];
            transforCell.lblState.text=[[self.arrhuachu objectAtIndex:indexPath.row] valueForKey:@"status"];
            transforCell.lblMoney.text=[NSString stringWithFormat:@"￥%@",[[self.arrhuachu objectAtIndex:indexPath.row] valueForKey:@"amountIn"]];
            NSString *strFees=@"10";
            transforCell.lblFees.text=[NSString stringWithFormat:@"手续费：%@元",strFees];
            
            cell = transforCell;
        }
            
            break;
            
        default:
            break;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    int i=0 ;
    switch (tableView.tag) {
        case 20:
            i=270;
            break;
        case 21:
            i=270;
            break;
            
        case 22:
            i=80;
            break;
            
        case 23:
            i=80;
            break;
            
        case 24
            :
            i=80;
            break;
            
        default:
            break;
    }
    return i;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView.tag==20) {
        NSString *str = [[unFinishProArr objectAtIndex:indexPath.row] persontage];
        NSLog(@"%@",str);
        NSRange rang1 =  [str rangeOfString:@"%"];
        NSString *strIndexTradeDetail=[NSString stringWithFormat:@"service=indexTradeDetail&tradeId=%@&demandId=%@",[[unFinishProArr objectAtIndex:indexPath.row] tradeId],[[unFinishProArr objectAtIndex:indexPath.row] demandId]];
        j =[str substringToIndex:rang1.location].floatValue;
        NSLog(@"%f",j);
        [[MYWebService new]getDataAsynWithKey:key  encryptedString:strIndexTradeDetail appKey:appKey];
        
        [self presentViewController:[InvestmentContentViewController new] animated:YES completion:nil];
    }else if(tableView.tag==21){
        NSString *str = [[finishProArr objectAtIndex:indexPath.row] persontage];
        NSLog(@"%@",str);
        NSRange rang1 =  [str rangeOfString:@"%"];
        NSString *strIndexTradeDetail=[NSString stringWithFormat:@"service=indexTradeDetail&tradeId=%@&demandId=%@",[[finishProArr objectAtIndex:indexPath.row] tradeId],[[finishProArr objectAtIndex:indexPath.row] demandId]];
        j =[str substringToIndex:rang1.location].floatValue;
        NSLog(@"%f",j);
        [[MYWebService new]getDataAsynWithKey:key  encryptedString:strIndexTradeDetail appKey:appKey];
        
        [self presentViewController:[InvestmentContentViewController new] animated:YES completion:nil];
    }
    switch (tableView.tag) {
        case 22:{
            TouZiXQ *xiangQin = [TouZiXQ new];
            xiangQin.tradeId = [[arrtouzi objectAtIndex:indexPath.row] valueForKey:@"tradeId"];
            NSLog(@"--tradeID---:%@",xiangQin.tradeId);
            xiangQin.detailId = [[arrtouzi objectAtIndex:indexPath.row] valueForKey:@"detailId"];
            NSLog(@"--tradeID---:%@",xiangQin.detailId);
            [self presentViewController:xiangQin animated:YES completion:nil];
            break;
        }
        default:
            break;
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [UIView new];
    if (tableView.tag==22) {
        view.frame = CGRectMake(0, 0, SCREEN_WIDTH, 60);
        UIImageView *sectionHeader = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 60)];
        sectionHeader.image = [UIImage imageNamed:@"biaotou_shouyi_bg"];
        UILabel *titileLable=[[UILabel alloc]initWithFrame:CGRectMake(30, 10, 300, 40)];
        countLable=[[UILabel alloc]initWithFrame:CGRectMake(500, 10, 200, 40)];
        titileLable.backgroundColor = [UIColor clearColor];
        titileLable.font=[UIFont systemFontOfSize:24];
        countLable.backgroundColor = [UIColor clearColor];
        countLable.font=[UIFont systemFontOfSize:24];
        titileLable.text = @"累计投资";
        countLable.text =@"￥";
        [view addSubview:sectionHeader];
        [view addSubview:titileLable];
        [view addSubview:countLable];
    }else {
        view = nil;
    }
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    int i = 0;
    if (tableView.tag==22) {
        i=60;
    }
    return i;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//刷新表
- (void)getNotifi:(NSNotification *)notification
{
    
    //    self.arrtouzi=[NSMutableArray arrayWithArray:[[self.serviceDataTouzi.profileDataAsyn valueForKey:@"result"] valueForKey:@"infos"]];
    //    self.arrhuaru=[NSMutableArray arrayWithArray:[[self.serviceDataHauru.profileDataAsyn valueForKey:@"result"] valueForKey:@"infos"]];
    //    self.arrhuachu=[NSMutableArray arrayWithArray:[[self.serviceDataHuachu.profileDataAsyn valueForKey:@"result"] valueForKey:@"infos"]];
    //    NSLog(@"%d",self.arrtouzi.count);
    
    [(UITableView *)[self.view viewWithTag:22] reloadData];
    [(UITableView *)[self.view viewWithTag:23] reloadData];
    [(UITableView *)[self.view viewWithTag:24] reloadData];
    
}
#pragma mark-   -----------状态栏底色------
- (UIStatusBarStyle)preferredStatusBarStyle
{
    [self.view setBackgroundColor:[UIColor blackColor]];
    return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden
{
    return NO;
}
@end
